#!/usr/bin/env python
#-*- coding:utf-8 -*-

def main0():
    root = r'D:\Develop\GitRepos\MOOC\北京理工大学\Python语言程序设计(第8期)\07'
    filename = '%s/%s' % (root, 'latex.log')
    with open(filename) as fp:
        content = fp.read()
    s = 0
    for line in content.split('\n'):
        if len(line) > 0:
            s += 1
    print("共{}行".format(s))

def main2(filename):
    with open(filename) as fp:
        content = fp.read()
    s = 0
    n = 0
    for line in content.split('\n'):
        if len(line) > 0:
            s += 1
            n += len(line)
    print("{}".format(int(round(n/s,0))))

def main(filename):
    with open(filename) as fp:
        content = fp.read()
    rows = content.split('\n')
    for row in reversed(rows):
        print(';'.join(reversed([i.strip() for i in row.split(',')])))

if __name__ == '__main__':
    #main(r'D:\Develop\GitRepos\MOOC\北京理工大学\Python语言程序设计(第8期)\07\latex.log')
    main(r'D:\Develop\GitRepos\MOOC\北京理工大学\Python语言程序设计(第8期)\07\data.csv')
    pass 